//
//  NotificationController.swift
//  test-ios
//
//  Created by wyz5204 on 2023/3/16.
//

import UIKit
import NSObject_Rx

class NotificationController: ABaseViewController {

    static let notice = NSNotification.Name("notice")
    
    static let NSplash = NSNotification.Name("NSplash")
    
    private lazy var button : UIButton = {
        return UIButton().then { view in
            view.setTitle("发送通知", for: UIControl.State.normal)
            view.setTitleColor(UIColor.red, for: UIControl.State.normal)
        }
    }()
    
    @objc func notifice(){
        print(self , type(of: self), "收到通知消息了")
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = .white
        
        registerObserver(selector: #selector(notifice) , name: Self.notice)
        weak var _self = self
        button.addTo(self.view) {view in
            
            view.rx.tap.asDriver().drive (onNext: {
                _self?.postMessage(Self.notice)
                _self?.postMessage(Self.NSplash)
            }).disposed(by: _self!.rx.disposeBag )
            
            view.snp.makeConstraints { make in
                make.top.equalToSuperview().offset(100)
            }
        }
        
    }
    

}
